package com.qitmiaojie.utils;


import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

public class BeanCopyUtils {
    public BeanCopyUtils(){
    }

    public static <V> V copyBean( Object source,Class<V> clazz){
        V result = null;
        try {
          result = clazz.newInstance();
            BeanUtils.copyProperties(source,result);
        }  catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
    public static <O,V> List<V> copyBeanList(List<O> list,Class<V> v) throws IllegalAccessException, InstantiationException {
        List<V> result = new ArrayList<>() ;
        for (O o : list) {
            V res = copyBean(o, v);
            result.add(res);
        }
        return result;
    }

    public static void main(String[] args) throws InstantiationException, IllegalAccessException {

    }
}
